package com.grz.service.impl;

import com.grz.dao.IUserDao;
import com.grz.service.IUserService;
import lombok.Setter;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

public class UserServiceImpl implements IUserService, InitializingBean, DisposableBean {

    @Setter
    private IUserDao userDao;

    @Setter
    private Integer number;

    public UserServiceImpl() {
        System.out.println("调用了无参构造....");
    }

    public UserServiceImpl(IUserDao userDao) {
        this.userDao = userDao;
    }

    public UserServiceImpl(IUserDao userDao, Integer number) {
        this.userDao = userDao;
        this.number = number;
    }

    @Override
    public int save(String username, String password) {
        userDao.save(username, password);
        System.out.println("计数器：" + number);
        return 0;
    }

    public void init123123213() {
        System.out.println("作为创建完成之后的生命周期...");
    }

    @Override
    public void destroy() {
        System.out.println("销毁的生命周期...");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("创建完成bean之后执行...");
    }
}
